import os,re

def r(p):
    f = open(p)
    s = f.read()
    f.close()
    return s


def w(p, s):
    f = open(p, 'w')
    f.write(s)
    f.close()


p=r'D:\Document_x64\Downloads\Compressed\apps\struts-blank-1.3.10'
for root,dirs,files in os.walk(p):
    for f in files:
        p = os.path.join(root, f)
        if f.endswith('.jsp'):
            s=r(p)
            s1 = re.sub(r'<%--[^>]+?--%>',r'', s,1)
            if s1 != s:
                print p
                w(p, s1)
        elif f.endswith('.xml') or f.endswith('.html'):
            s = r(p)
            s1 = re.sub(r'<!--[^>]+?-->', r'', s, 1)
            if s1 != s:
                print p
                w(p, s1)
        elif f.endswith('.java'):
            s = r(p)
            s1 = re.sub(r'/\*[^>]+?\*/', r'', s, 1)
            if s1 != s:
                print p
                w(p, s1)
        elif f.endswith('.properties'):
            s = r(p)
            s1 = re.sub(r'(?:#.*\n)+\s\s', r'', s,1)
            if s1 != s:
                print p
                w(p, s1)


